home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 February: Tool Chest / Apple Developer CD Series Tool Chest February 1996 (Apple Computer)(1996).iso / Tool Chest / Interfaces & Libraries / Interfaces / CIncludes / FileTransfers.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-07-06  |  15.5 KB  |  372 lines  |  [TEXT/MPS ]

  1. /*
  2.      File:        FileTransfers.h
  3.  
  4.      Contains:    CommToolbox File Transfer Manager Interfaces.
  5.  
  6.      Version:    Technology:    System 7.5
  7.                  Package:    Universal Interfaces 2.1 in “MPW Latest” on ETO #18
  8.  
  9.      Copyright:    © 1984-1995 by Apple Computer, Inc.
  10.                  All rights reserved.
  11.  
  12.      Bugs?:        If you find a problem with this file, use the Apple Bug Reporter
  13.                  stack.  Include the file and version information (from above)
  14.                  in the problem description and send to:
  15.                      Internet:    apple.bugs@applelink.apple.com
  16.                      AppleLink:    APPLE.BUGS
  17.  
  18. */
  19.  
  20. #ifndef __FILETRANSFERS__
  21. #define __FILETRANSFERS__
  22.  
  23.  
  24. #ifndef __WINDOWS__
  25. #include <Windows.h>
  26. #endif
  27. /*    #include <Types.h>                                            */
  28. /*        #include <ConditionalMacros.h>                            */
  29. /*    #include <Memory.h>                                            */
  30. /*        #include <MixedMode.h>                                    */
  31. /*    #include <Quickdraw.h>                                        */
  32. /*        #include <QuickdrawText.h>                                */
  33. /*    #include <Events.h>                                            */
  34. /*        #include <OSUtils.h>                                    */
  35. /*    #include <Controls.h>                                        */
  36. /*        #include <Menus.h>                                        */
  37.  
  38. #ifndef __CTBUTILITIES__
  39. #include <CTBUtilities.h>
  40. #endif
  41. /*    #include <Dialogs.h>                                        */
  42. /*        #include <Errors.h>                                        */
  43. /*        #include <TextEdit.h>                                    */
  44. /*    #include <StandardFile.h>                                    */
  45. /*        #include <Files.h>                                        */
  46. /*            #include <Finder.h>                                    */
  47. /*    #include <AppleTalk.h>                                        */
  48.  
  49. #ifndef __CONNECTIONS__
  50. #include <Connections.h>
  51. #endif
  52.  
  53. #ifndef __FILES__
  54. #include <Files.h>
  55. #endif
  56.  
  57. #ifndef __TERMINALS__
  58. #include <Terminals.h>
  59. #endif
  60.  
  61. #ifdef __cplusplus
  62. extern "C" {
  63. #endif
  64.  
  65. #if PRAGMA_ALIGN_SUPPORTED
  66. #pragma options align=mac68k
  67. #endif
  68.  
  69. #if PRAGMA_IMPORT_SUPPORTED
  70. #pragma import on
  71. #endif
  72.  
  73.  
  74. enum {
  75. /* current file transfer manager version    */
  76.     curFTVersion                = 2,
  77. /* FTErr    */
  78.     ftGenericError                = -1,
  79.     ftNoErr                        = 0,
  80.     ftRejected                    = 1,
  81.     ftFailed                    = 2,
  82.     ftTimeOut                    = 3,
  83.     ftTooManyRetry                = 4,
  84.     ftNotEnoughDSpace            = 5,
  85.     ftRemoteCancel                = 6,
  86.     ftWrongFormat                = 7,
  87.     ftNoTools                    = 8,
  88.     ftUserCancel                = 9,
  89.     ftNotSupported                = 10
  90. };
  91.  
  92. typedef OSErr FTErr;
  93.  
  94.  
  95. enum {
  96.     ftIsFTMode                    = 1 << 0,
  97.     ftNoMenus                    = 1 << 1,
  98.     ftQuiet                        = 1 << 2,
  99.     ftConfigChanged                = 1 << 4,
  100.     ftSucc                        = 1 << 7
  101. };
  102.  
  103. typedef unsigned long FTFlags;
  104.  
  105.  
  106. enum {
  107.     ftSameCircuit                = 1 << 0,
  108.     ftSendDisable                = 1 << 1,
  109.     ftReceiveDisable            = 1 << 2,
  110.     ftTextOnly                    = 1 << 3,
  111.     ftNoStdFile                    = 1 << 4,
  112.     ftMultipleFileSend            = 1 << 5
  113. };
  114.  
  115. typedef unsigned short FTAttributes;
  116.  
  117.  
  118. enum {
  119.     ftReceiving,
  120.     ftTransmitting
  121. };
  122.  
  123. typedef unsigned short FTDirection;
  124.  
  125. /*    application routines type definitions */
  126. typedef struct FTRecord FTRecord, *FTPtr, **FTHandle;
  127.  
  128. typedef pascal long (*FileTransferDefProcPtr)(TermHandle hTerm, short msg, long p1, long p2, long p3);
  129. typedef pascal OSErr (*FileTransferReadProcPtr)(unsigned long *count, Ptr pData, long refCon, short fileMsg);
  130. typedef pascal OSErr (*FileTransferWriteProcPtr)(unsigned long *count, Ptr pData, long refCon, short fileMsg);
  131. typedef pascal Size (*FileTransferSendProcPtr)(Ptr thePtr, long theSize, long refCon, CMChannel channel, CMFlags flag);
  132. typedef pascal Size (*FileTransferReceiveProcPtr)(Ptr thePtr, long theSize, long refCon, CMChannel channel, CMFlags *flag);
  133. typedef pascal OSErr (*FileTransferEnvironsProcPtr)(long refCon, ConnEnvironRec *theEnvirons);
  134. typedef pascal void (*FileTransferNotificationProcPtr)(FTHandle hFT, FSSpecPtr pFSSpec);
  135. typedef pascal void (*FileTransferChooseIdleProcPtr)(void);
  136.  
  137. #if GENERATINGCFM
  138. typedef UniversalProcPtr FileTransferDefUPP;
  139. typedef UniversalProcPtr FileTransferReadUPP;
  140. typedef UniversalProcPtr FileTransferWriteUPP;
  141. typedef UniversalProcPtr FileTransferSendUPP;
  142. typedef UniversalProcPtr FileTransferReceiveUPP;
  143. typedef UniversalProcPtr FileTransferEnvironsUPP;
  144. typedef UniversalProcPtr FileTransferNotificationUPP;
  145. typedef UniversalProcPtr FileTransferChooseIdleUPP;
  146. #else
  147. typedef FileTransferDefProcPtr FileTransferDefUPP;
  148. typedef FileTransferReadProcPtr FileTransferReadUPP;
  149. typedef FileTransferWriteProcPtr FileTransferWriteUPP;
  150. typedef FileTransferSendProcPtr FileTransferSendUPP;
  151. typedef FileTransferReceiveProcPtr FileTransferReceiveUPP;
  152. typedef FileTransferEnvironsProcPtr FileTransferEnvironsUPP;
  153. typedef FileTransferNotificationProcPtr FileTransferNotificationUPP;
  154. typedef FileTransferChooseIdleProcPtr FileTransferChooseIdleUPP;
  155. #endif
  156.  
  157. struct FTRecord {
  158.     short                            procID;
  159.     FTFlags                            flags;
  160.     FTErr                            errCode;
  161.     long                            refCon;
  162.     long                            userData;
  163.     FileTransferDefUPP                defProc;
  164.     Ptr                                config;
  165.     Ptr                                oldConfig;
  166.     FileTransferEnvironsUPP            environsProc;
  167.     long                            reserved1;
  168.     long                            reserved2;
  169.     Ptr                                ftPrivate;
  170.     FileTransferSendUPP                sendProc;
  171.     FileTransferReceiveUPP            recvProc;
  172.     FileTransferWriteUPP            writeProc;
  173.     FileTransferReadUPP                readProc;
  174.     WindowPtr                        owner;
  175.     FTDirection                        direction;
  176.     SFReply                            theReply;
  177.     long                            writePtr;
  178.     long                            readPtr;
  179.     char                            *theBuf;
  180.     long                            bufSize;
  181.     Str255                            autoRec;
  182.     FTAttributes                    attributes;
  183. };
  184.  
  185. enum {
  186. /* FTReadProc messages */
  187.     ftReadOpenFile                = 0,                            /* count = forkFlags, buffer = pblock from PBGetFInfo */
  188.     ftReadDataFork                = 1,
  189.     ftReadRsrcFork                = 2,
  190.     ftReadAbort                    = 3,
  191.     ftReadComplete                = 4,
  192.     ftReadSetFPos                = 6,                            /* count = forkFlags, buffer = pBlock same as PBSetFPos */
  193.     ftReadGetFPos                = 7,                            /* count = forkFlags, buffer = pBlock same as PBGetFPos */
  194. /* FTWriteProc messages */
  195.     ftWriteOpenFile                = 0,                            /* count = forkFlags, buffer = pblock from PBGetFInfo */
  196.     ftWriteDataFork                = 1,
  197.     ftWriteRsrcFork                = 2,
  198.     ftWriteAbort                = 3,
  199.     ftWriteComplete                = 4,
  200.     ftWriteFileInfo                = 5,
  201.     ftWriteSetFPos                = 6,                            /* count = forkFlags, buffer = pBlock same as PBSetFPos */
  202.     ftWriteGetFPos                = 7,                            /* count = forkFlags, buffer = pBlock same as PBGetFPos */
  203. /*    fork flags */
  204.     ftOpenDataFork                = 1,
  205.     ftOpenRsrcFork                = 2
  206. };
  207.  
  208. enum {
  209.     uppFileTransferDefProcInfo = kPascalStackBased
  210.          | RESULT_SIZE(SIZE_CODE(sizeof(long)))
  211.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(TermHandle)))
  212.          | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(short)))
  213.          | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(long)))
  214.          | STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(long)))
  215.          | STACK_ROUTINE_PARAMETER(5, SIZE_CODE(sizeof(long))),
  216.     uppFileTransferReadProcInfo = kPascalStackBased
  217.          | RESULT_SIZE(SIZE_CODE(sizeof(OSErr)))
  218.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(unsigned long*)))
  219.          | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(Ptr)))
  220.          | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(long)))
  221.          | STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(short))),
  222.     uppFileTransferWriteProcInfo = kPascalStackBased
  223.          | RESULT_SIZE(SIZE_CODE(sizeof(OSErr)))
  224.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(unsigned long*)))
  225.          | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(Ptr)))
  226.          | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(long)))
  227.          | STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(short))),
  228.     uppFileTransferSendProcInfo = kPascalStackBased
  229.          | RESULT_SIZE(SIZE_CODE(sizeof(Size)))
  230.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(Ptr)))
  231.          | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(long)))
  232.          | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(long)))
  233.          | STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(CMChannel)))
  234.          | STACK_ROUTINE_PARAMETER(5, SIZE_CODE(sizeof(CMFlags))),
  235.     uppFileTransferReceiveProcInfo = kPascalStackBased
  236.          | RESULT_SIZE(SIZE_CODE(sizeof(Size)))
  237.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(Ptr)))
  238.          | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(long)))
  239.          | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(long)))
  240.          | STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(CMChannel)))
  241.          | STACK_ROUTINE_PARAMETER(5, SIZE_CODE(sizeof(CMFlags*))),
  242.     uppFileTransferEnvironsProcInfo = kPascalStackBased
  243.          | RESULT_SIZE(SIZE_CODE(sizeof(OSErr)))
  244.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(long)))
  245.          | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(ConnEnvironRec*))),
  246.     uppFileTransferNotificationProcInfo = kPascalStackBased
  247.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(FTHandle)))
  248.          | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(FSSpecPtr))),
  249.     uppFileTransferChooseIdleProcInfo = kPascalStackBased
  250. };
  251.  
  252. #if GENERATINGCFM
  253. #define NewFileTransferDefProc(userRoutine)        \
  254.         (FileTransferDefUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppFileTransferDefProcInfo, GetCurrentArchitecture())
  255. #define NewFileTransferReadProc(userRoutine)        \
  256.         (FileTransferReadUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppFileTransferReadProcInfo, GetCurrentArchitecture())
  257. #define NewFileTransferWriteProc(userRoutine)        \
  258.         (FileTransferWriteUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppFileTransferWriteProcInfo, GetCurrentArchitecture())
  259. #define NewFileTransferSendProc(userRoutine)        \
  260.         (FileTransferSendUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppFileTransferSendProcInfo, GetCurrentArchitecture())
  261. #define NewFileTransferReceiveProc(userRoutine)        \
  262.         (FileTransferReceiveUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppFileTransferReceiveProcInfo, GetCurrentArchitecture())
  263. #define NewFileTransferEnvironsProc(userRoutine)        \
  264.         (FileTransferEnvironsUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppFileTransferEnvironsProcInfo, GetCurrentArchitecture())
  265. #define NewFileTransferNotificationProc(userRoutine)        \
  266.         (FileTransferNotificationUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppFileTransferNotificationProcInfo, GetCurrentArchitecture())
  267. #define NewFileTransferChooseIdleProc(userRoutine)        \
  268.         (FileTransferChooseIdleUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppFileTransferChooseIdleProcInfo, GetCurrentArchitecture())
  269. #else
  270. #define NewFileTransferDefProc(userRoutine)        \
  271.         ((FileTransferDefUPP) (userRoutine))
  272. #define NewFileTransferReadProc(userRoutine)        \
  273.         ((FileTransferReadUPP) (userRoutine))
  274. #define NewFileTransferWriteProc(userRoutine)        \
  275.         ((FileTransferWriteUPP) (userRoutine))
  276. #define NewFileTransferSendProc(userRoutine)        \
  277.         ((FileTransferSendUPP) (userRoutine))
  278. #define NewFileTransferReceiveProc(userRoutine)        \
  279.         ((FileTransferReceiveUPP) (userRoutine))
  280. #define NewFileTransferEnvironsProc(userRoutine)        \
  281.         ((FileTransferEnvironsUPP) (userRoutine))
  282. #define NewFileTransferNotificationProc(userRoutine)        \
  283.         ((FileTransferNotificationUPP) (userRoutine))
  284. #define NewFileTransferChooseIdleProc(userRoutine)        \
  285.         ((FileTransferChooseIdleUPP) (userRoutine))
  286. #endif
  287.  
  288. #if GENERATINGCFM
  289. #define CallFileTransferDefProc(userRoutine, hTerm, msg, p1, p2, p3)        \
  290.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppFileTransferDefProcInfo, (hTerm), (msg), (p1), (p2), (p3))
  291. #define CallFileTransferReadProc(userRoutine, count, pData, refCon, fileMsg)        \
  292.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppFileTransferReadProcInfo, (count), (pData), (refCon), (fileMsg))
  293. #define CallFileTransferWriteProc(userRoutine, count, pData, refCon, fileMsg)        \
  294.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppFileTransferWriteProcInfo, (count), (pData), (refCon), (fileMsg))
  295. #define CallFileTransferSendProc(userRoutine, thePtr, theSize, refCon, channel, flag)        \
  296.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppFileTransferSendProcInfo, (thePtr), (theSize), (refCon), (channel), (flag))
  297. #define CallFileTransferReceiveProc(userRoutine, thePtr, theSize, refCon, channel, flag)        \
  298.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppFileTransferReceiveProcInfo, (thePtr), (theSize), (refCon), (channel), (flag))
  299. #define CallFileTransferEnvironsProc(userRoutine, refCon, theEnvirons)        \
  300.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppFileTransferEnvironsProcInfo, (refCon), (theEnvirons))
  301. #define CallFileTransferNotificationProc(userRoutine, hFT, pFSSpec)        \
  302.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppFileTransferNotificationProcInfo, (hFT), (pFSSpec))
  303. #define CallFileTransferChooseIdleProc(userRoutine)        \
  304.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppFileTransferChooseIdleProcInfo)
  305. #else
  306. #define CallFileTransferDefProc(userRoutine, hTerm, msg, p1, p2, p3)        \
  307.         (*(userRoutine))((hTerm), (msg), (p1), (p2), (p3))
  308. #define CallFileTransferReadProc(userRoutine, count, pData, refCon, fileMsg)        \
  309.         (*(userRoutine))((count), (pData), (refCon), (fileMsg))
  310. #define CallFileTransferWriteProc(userRoutine, count, pData, refCon, fileMsg)        \
  311.         (*(userRoutine))((count), (pData), (refCon), (fileMsg))
  312. #define CallFileTransferSendProc(userRoutine, thePtr, theSize, refCon, channel, flag)        \
  313.         (*(userRoutine))((thePtr), (theSize), (refCon), (channel), (flag))
  314. #define CallFileTransferReceiveProc(userRoutine, thePtr, theSize, refCon, channel, flag)        \
  315.         (*(userRoutine))((thePtr), (theSize), (refCon), (channel), (flag))
  316. #define CallFileTransferEnvironsProc(userRoutine, refCon, theEnvirons)        \
  317.         (*(userRoutine))((refCon), (theEnvirons))
  318. #define CallFileTransferNotificationProc(userRoutine, hFT, pFSSpec)        \
  319.         (*(userRoutine))((hFT), (pFSSpec))
  320. #define CallFileTransferChooseIdleProc(userRoutine)        \
  321.         (*(userRoutine))()
  322. #endif
  323.  
  324. extern pascal FTErr InitFT(void);
  325. extern pascal Handle FTGetVersion(FTHandle hFT);
  326. extern pascal short FTGetFTVersion(void);
  327. extern pascal FTHandle FTNew(short procID, FTFlags flags, FileTransferSendUPP sendProc, FileTransferReceiveUPP recvProc, FileTransferReadUPP readProc, FileTransferWriteUPP writeProc, FileTransferEnvironsUPP environsProc, WindowPtr owner, long refCon, long userData);
  328. extern pascal void FTDispose(FTHandle hFT);
  329. extern pascal FTErr FTStart(FTHandle hFT, FTDirection direction, const SFReply *fileInfo);
  330. extern pascal FTErr FTAbort(FTHandle hFT);
  331. extern pascal FTErr FTSend(FTHandle hFT, short numFiles, FSSpecArrayPtr pFSSpec, FileTransferNotificationUPP notifyProc);
  332. extern pascal FTErr FTReceive(FTHandle hFT, FSSpecPtr pFSSpec, FileTransferNotificationUPP notifyProc);
  333. extern pascal void FTExec(FTHandle hFT);
  334. extern pascal void FTActivate(FTHandle hFT, Boolean activate);
  335. extern pascal void FTResume(FTHandle hFT, Boolean resume);
  336. extern pascal Boolean FTMenu(FTHandle hFT, short menuID, short item);
  337. extern pascal short FTChoose(FTHandle *hFT, Point where, FileTransferChooseIdleUPP idleProc);
  338. extern pascal void FTEvent(FTHandle hFT, const EventRecord *theEvent);
  339. extern pascal Boolean FTValidate(FTHandle hFT);
  340. extern pascal void FTDefault(Ptr *theConfig, short procID, Boolean allocate);
  341. extern pascal Handle FTSetupPreflight(short procID, long *magicCookie);
  342. extern pascal void FTSetupSetup(short procID, const void *theConfig, short count, DialogPtr theDialog, long *magicCookie);
  343. extern pascal Boolean FTSetupFilter(short procID, const void *theConfig, short count, DialogPtr theDialog, EventRecord *theEvent, short *theItem, long *magicCookie);
  344. extern pascal void FTSetupItem(short procID, const void *theConfig, short count, DialogPtr theDialog, short *theItem, long *magicCookie);
  345. extern pascal void FTSetupXCleanup(short procID, const void *theConfig, short count, DialogPtr theDialog, Boolean OKed, long *magicCookie);
  346. extern pascal void FTSetupPostflight(short procID);
  347. extern pascal Ptr FTGetConfig(FTHandle hFT);
  348. extern pascal short FTSetConfig(FTHandle hFT, const void *thePtr);
  349. extern pascal OSErr FTIntlToEnglish(FTHandle hFT, const void *inputPtr, Ptr *outputPtr, short language);
  350. extern pascal OSErr FTEnglishToIntl(FTHandle hFT, const void *inputPtr, Ptr *outputPtr, short language);
  351. extern pascal void FTGetToolName(short procID, Str255 name);
  352. extern pascal short FTGetProcID(ConstStr255Param name);
  353. extern pascal void FTSetRefCon(FTHandle hFT, long refCon);
  354. extern pascal long FTGetRefCon(FTHandle hFT);
  355. extern pascal void FTSetUserData(FTHandle hFT, long userData);
  356. extern pascal long FTGetUserData(FTHandle hFT);
  357. extern pascal void FTGetErrorString(FTHandle hFT, short id, Str255 errMsg);
  358.  
  359. #if PRAGMA_IMPORT_SUPPORTED
  360. #pragma import off
  361. #endif
  362.  
  363. #if PRAGMA_ALIGN_SUPPORTED
  364. #pragma options align=reset
  365. #endif
  366.  
  367. #ifdef __cplusplus
  368. }
  369. #endif
  370.  
  371. #endif /* __FILETRANSFERS__ */
  372.